import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { userSelect } from '/@/api/backs/system/user';
import moment from 'moment';

export const columns: BasicColumn[] = [
  {
    title: '标题',
    dataIndex: 'title',
  },
  {
    title: '描述',
    dataIndex: 'description',
  },
  {
    title: '日期',
    dataIndex: 'expireDate',
  },
  {
    title: '时间',
    dataIndex: 'expireTime',
    customRender: ({ record }) => {
      const time = record.expireTime;
      return time ? moment(time).format('hh:mm:ss') : '-';
    },
  },
  {
    title: '是否过期',
    dataIndex: 'expired',
    customRender: ({ record }) => {
      if (record.hasProbation) {
        return '是';
      } else {
        return '否';
      }
    },
  },
  {
    title: '创建者',
    dataIndex: 'userId',
  },

  {
    title: '创建时间',
    dataIndex: 'createdAt',
    customRender: ({ record }) => {
      const time = record.createdAt;
      return time ? moment(time).format('YYYY-MM-DD') : '-';
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'createTime',
    label: '创建时间',
    component: 'RangePicker',
    colProps: { span: 8 },
    componentProps: {
      valueFormat: 'X',
    },
  },
  {
    field: 'title',
    label: '标题',
    component: 'Input',
    colProps: { span: 8 },
    componentProps: {
      placeholder: '请输入标题',
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'id',
    component: 'Input',
    ifShow: false,
  },
  {
    field: 'title',
    label: '标题',
    component: 'Input',
    required: true,
    componentProps: {
      placeholder: '请输入标题',
    },
  },
  {
    field: 'description',
    label: '描述',
    component: 'InputTextArea',
    required: true,
    componentProps: {
      placeholder: '请输入描述',
    },
  },
  {
    field: 'expireDate',
    label: '日期',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'x',
    },
  },
  {
    field: 'expireTime',
    label: '时间',
    component: 'TimePicker',
    componentProps: {
      valueFormat: 'x',
    },
  },
  {
    field: 'hasProbation',
    label: '是否过期',
    defaultValue: true,
    component: 'Switch',
    colProps: { span: 8 },
    required: true,
    componentProps: {
      checkedValue: true,
      unCheckedValue: false,
    },
  },
];
